#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int t;
	while(cin>>t){
		for(int i=0;i<t;i++){
			int geshu;
			cin>>geshu;
			int a[10000];
			for(int j=0;j<geshu;j++) cin>>a[j];
			int b[10000];
			int jishu=0;
			for(int k=0;k<geshu;k++){
				if(a[k]==-1) continue;
				b[jishu]=a[k];
				jishu++;
				for(int kk=k+1;kk<geshu;kk++){
					if(a[kk]==a[k]){
						a[kk]=-1;
					}
				}
				
			}
			
			sort(b,b+jishu);
			cout<<jishu<<endl;
			for(int m=0;m<jishu;m++){
				if(m==jishu-1) cout<<b[m]<<endl;
				else cout<<b[m]<<" ";
			}
			
		}
		
	}
}
